import { defineStore } from "pinia";
/*
    id: 1,
    source: "57",
    target: "59",
    jitter: 0.1,
    latency: 10,
    bandwidthUtilization: 0.1,
    createdTime: '2021-10-01 12:00:00',
*/


export const useLinkDataStore = defineStore({
    id: "link_data",
    state() {
        return {
            links: [
                {
                    id: 1,
                    source: "57",
                    target: "59",
                    jitter: 0.1,
                    latency: 10,
                    bandwidthUtilization: 0.1,
                    createdTime: '2021-10-01 12:00:00',
                },
                {
                    id: 2,
                    source: "57",
                    target: "61",
                    jitter: 0.2,
                    latency: 20,
                    bandwidthUtilization: 0.2,
                    createdTime: '2021-10-01 12:00:00',
                },
                {
                    id: 3,
                    source: "61",
                    target: "59",
                    jitter: 0.3,
                    latency: 30,
                    bandwidthUtilization: 0.3,
                    createdTime: '2021-10-01 12:00:00',
                },

            ],

        };
    },
    actions: {
        getRandomLink() {
            let link = {
                id: Math.floor(Math.random() * 100),
                source: '',
                target: '',
                jitter: Math.random().toFixed(1),
                latency: Math.floor(Math.random() * 100),
                bandwidthUtilization: Math.random().toFixed(1),
                createdTime: new Date().toLocaleString(),
            }
            return link;
        }
    }
});